From: Christian Korber Date: Tue, 9 Sep 2025 08:51:56 +0000 (+0200) Subject: luci-mod-status: add vendor info in index file X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=7b07b93ff94c4cb6fa2a51631b6eeb24d6799455;p=project%2Fluci.git luci-mod-status: add vendor info in index file In the overview page are all active dhcp leases displayed. For easier recognition, the listed MAC addresses fo these leases are resolved to their vendor names. Signed-off-by: Christian Korber --- diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js index a98906f9fe..27e903f2cd 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js @@ -11,6 +11,17 @@ var callLuciDHCPLeases = rpc.declare({ expect: { '': {} } }); +var callUfpList = rpc.declare({ + object: 'fingerprint', + method: 'fingerprint', +}); + +var checkUfpInstalled = rpc.declare({ + object: 'file', + method: 'stat', + params: [ 'path' ] +}); + return baseclass.extend({ title: '', @@ -19,10 +30,17 @@ return baseclass.extend({ load: function() { return Promise.all([ - callLuciDHCPLeases(), - network.getHostHints(), - L.resolveDefault(uci.load('dhcp')) - ]); + checkUfpInstalled('/usr/sbin/ufpd') + ]).then(data => { + var promises = [ + callLuciDHCPLeases(), + network.getHostHints(), + data[0].type === 'file' ? callUfpList() : null, + L.resolveDefault(uci.load('dhcp')) + ]; + + return Promise.all(promises); + }); }, handleCreateStaticLease: function(lease, ev) { @@ -64,6 +82,7 @@ return baseclass.extend({ leases6 = Array.isArray(data[0].dhcp6_leases) ? data[0].dhcp6_leases : [], machints = data[1].getMACHints(false), hosts = uci.sections('dhcp', 'host'), + macaddr = data[2], isReadonlyView = !L.hasViewPermission(); for (var i = 0; i < hosts.length; i++) { @@ -94,6 +113,7 @@ return baseclass.extend({ cbi_update_table(table, leases.map(L.bind(function(lease) { var exp, rows; + var vendor; if (lease.expires === false) exp = E('em', _('unlimited')); @@ -110,10 +130,15 @@ return baseclass.extend({ else if (lease.hostname) host = lease.hostname; + if (macaddr) { + var lowermac = lease.macaddr.toLowerCase(); + vendor = macaddr[lowermac].vendor ? macaddr[lowermac].vendor : null; + } + rows = [ host || '-', lease.ipaddr, - lease.macaddr, + vendor ? lease.macaddr + ` (${vendor})` : lease.macaddr, exp ]; diff --git a/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status-index.json b/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status-index.json index 99b4d02b1d..3fda239775 100644 --- a/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status-index.json +++ b/modules/luci-mod-status/root/usr/share/rpcd/acl.d/luci-mod-status-index.json @@ -33,7 +33,9 @@ "description": "Grant access to DHCP status display", "read": { "ubus": { - "luci-rpc": [ "getDHCPLeases" ] + "luci-rpc": [ "getDHCPLeases" ], + "fingerprint": [ "fingerprint" ], + "file": [ "stat" ] } } },